package com.ruoyi.hqfinance.controller;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.hqfinance.domain.HqOtherFeeLastThree;
import com.ruoyi.hqfinance.domain.HqOtherFeeShortBargeFee;
import com.ruoyi.hqfinance.domain.vo.HqOtherFeeLastThreeVo;
import com.ruoyi.hqfinance.domain.vo.HqOtherFeeShortBargeFeeVo;
import com.ruoyi.hqfinance.service.HqOtherFeeService;
import com.ruoyi.logistic.domain.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/hq/otherFee")
@Api(tags = "总部财务-其他费用报表")
public class HqOtherFeeController {
    @Autowired
    private HqOtherFeeService hqOtherFeeService;


    @ApiOperation("前两条")
    @PostMapping("/shortBargeFee")
    public R collectShortBargeFee(@RequestBody HqOtherFeeShortBargeFeeVo vo) {
        if (vo.getEndTime() == null || vo.getStartTime() == null || vo.getNetworkNameId() == null){
            return R.fail("请输入必要的查询条件！");
        }
        List<HqOtherFeeShortBargeFee> shortBargeFees = hqOtherFeeService.collectBargeFee(vo);
        if (shortBargeFees == null || shortBargeFees.size() == 0) {
            return R.fail("暂无数据");
        } else {
            return R.ok(PageInfo.info(shortBargeFees));
        }
    }

    @ApiOperation("后三条")
    @PostMapping("/lastThree")
    public R collectLastThree(@RequestBody HqOtherFeeLastThreeVo vo) {
        if (vo.getEndTime() == null || vo.getStartTime() == null || vo.getNetworkNameId() == null){
            return R.fail("请输入必要的查询条件！");
        }
        List<HqOtherFeeLastThree> lastThrees = hqOtherFeeService.collectLastThree(vo);
        if (lastThrees == null || lastThrees.size() == 0) {
            return R.fail("暂无数据");
        } else {
            return R.ok(PageInfo.info(lastThrees));
        }
    }

}
